from Deepmind WaveNet paper:

$$ f(x_t) = \mathrm{sign}(x_t) \frac{\mathrm{ln}(1 + \mu |X_t|)}{\mathrm{ln}(1+\mu)} $$

In [8]:
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

In [11]:
F = lambda u: lambda x_t : np.sign(x_t) * np.log(1 + u * np.abs(x_t)) / np.log(1 + u)

In [20]:
xs = np.linspace(-100, 100)
ys = list(map(F(1.0), xs))

plt.plot(xs, ys)
plt.title('$\mu$-law companding transformation', fontsize=16)


Out[20]:
<matplotlib.text.Text at 0x10cdd69e8>

Log


In [22]:
log_x = list(map(np.log, xs))
plt.plot(xs, log_x)


/Users/ge/anaconda/envs/python3/lib/python3.5/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in log
  if __name__ == '__main__':
Out[22]:
[<matplotlib.lines.Line2D at 0x10d01de80>]

Tanh


In [33]:
xs = np.linspace(-5, 5)
tanh_x = list(map(np.tanh, xs))
plt.plot(xs, np.real(tanh_x))
plt.plot(xs, np.imag(tanh_x))


Out[33]:
[<matplotlib.lines.Line2D at 0x10d107470>]

In [ ]: